import socket
from time import sleep

def main():
    # Create a socket
    udp_send_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

    # Specify the IP address and port of receiver.
    ip_addr = '127.0.0.1'
    port = 8848
    port2 = 8849
    port3 = 8850
    dest_addr = (ip_addr, port) 
    dest_addr2 = (ip_addr, port2) 
    dest_addr3 = (ip_addr, port3) 
	# When you want to transmit more data, please add a loop.
    counter = 0
    raw=0
    while True: 
        if counter==150:
            counter=0
        if raw==360:
            raw=0
        #send_data = input("Your data is: ")
        send_data=str(counter+100)
        send_raw=str(raw+100)

        udp_send_socket.sendto(send_data.encode("utf-8"), dest_addr) # dest_addr is a tuple.
        udp_send_socket.sendto(send_data.encode("utf-8"), dest_addr2) # dest_addr is a tuple.
        udp_send_socket.sendto(send_raw.encode("utf-8"), dest_addr3) # dest_addr is a tuple.

        print(str(send_data.encode("utf-8"))+'raw:'+str(raw))
		# if input is 'exit', then jump out of the loop.
        if send_data.lower() == 'exit':
            break
        counter+=1
        raw+=5
        sleep(0.2)
	# Close the socket.
    udp_send_socket.close()

if __name__ == "__main__":
	main()

